#ifndef WORD_H
#define WORD_H

#include <QtGui>
#include <QtSql>
#include <vector>
#include "window.h"
#include "scorer.h"
#include "ResultItem.h"
#include "query.h"
using namespace std;

class InputWin;

class Word : public QWidget {

Q_OBJECT
  public:
    static const int NOUN = 0;
    static const int VERB = 1;
    static const int AUX = 2;
    static const int ITEMINFO = Qt::UserRole;
    static const int ITEMTYPE = Qt::UserRole+1;
    static const int FILEITEM = 1;
    static const int TEXTITEM = 2;
    static const int CDUP = 0;
    static const int CDDOWN = 1;
    static const int CDHOME = 2;
    QString DBTABLE;
    QSettings settings;
    Word(InputWin *parent = 0, int pType = 0);
    int type;
    Query * query;
    QListWidget * resultsBox;
    QLabel * status;
    QDir fileBrowser;
    QStringList curFileList;
    QString oldQuery;
    QString defDir;
    QSqlQuery sqlQ;
    void changeDirectory(int type);
    void changeSelection(bool backwards);
    QStringList getFileList(bool recur);
    void addResults(QString searchString, bool filterDown);
    string getSelectedPath();
    int getVerbSubType(string path);
    bool hasSelection();
    int currentSelectionType();
    bool makeRecurMode;
    bool browseMode;
    int typeFilter;
  private:
    QList<ResultItem> scoreFiles(QStringList list, QString match);
    vector<string> QStringListToVector(QStringList list);
    QStringList recurBrowse(QString dir, int iter);
    bool isVerb(string path);
    string getVerbName(string path);
  public slots:
    void entered();
    void edited(const QString& = QString(), bool reload = false);
    void loadIcon(ResultItem *);
    void newSelection(QListWidgetItem *, QListWidgetItem *);
    void handleKey(QKeyEvent *);
  signals:
    void itemApproached(ResultItem *);
    void newSelected();
};

#endif
